package cn.itcast.sy7.servlet;

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "MyServlet", value = "/MyServlet")

public class MyServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // 设置响应内容类型
        response        .setContentType("text/html");
        // 获取响应的输出流
        PrintWriter out = response.getWriter();
        // 向浏览器输出内容
        out.write("Hello MyServlet------ ");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // 对于POST请求，简单地调用doGet方法处理
        doGet(request, response);
    }
}